package com.cq.hd.app.controller;

import com.cq.hd.common.annotation.LoginUser;
import com.cq.hd.common.entity.AppLoginUser;
import com.cq.hd.common.enums.biz.PlatformTypeEnum;
import com.cq.hd.common.response.Result;
import com.cq.hd.member.api.PopRecordApi;
import com.cq.hd.member.api.dto.PopRecordSaveDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/popRecord")
@Api(tags = "弹窗相关接口")
public class PopRecordController {

    @Autowired
    private PopRecordApi popRecordApi;

    @ApiOperation(value = "弹窗")
    @ApiImplicitParam(name = "popType", value = "弹窗类型(1-商家入驻/2-商户入驻)", paramType = "path", dataType = "Integer")
    @GetMapping("/save/{popType}")
    public Result<Boolean> save(@ApiIgnore @LoginUser AppLoginUser appLoginUser, @PathVariable("popType") Integer popType) {
        PopRecordSaveDto popRecordSaveDto = new PopRecordSaveDto();
        popRecordSaveDto.setPlatformType(PlatformTypeEnum.BUSINESS.getValue());
        popRecordSaveDto.setPopType(popType);
        popRecordSaveDto.setUserId(appLoginUser.getUserId());
        popRecordSaveDto.setCreateTime(LocalDateTime.now());
        return popRecordApi.savePopRecord(popRecordSaveDto);
    }


}
